<script>
export default {
	onLaunch: function(option) {
		console.log('App Launch');
		console.log('App lof');
		//#ifdef MP-TOUTIAO
			this.globalData.toutiao=option.query
	
			console.log(this.globalData)
		//#endif
	},
	onLoad:function(option){
	
	},
	onShow: function() {
	
		uni.login({
		
			success: (code) => {
				console.log(code)
				//#ifdef MP-WEIXIN
				this.$api.loginCode({
					code: code.code,
					type: 0
				}).then(res => {
					this.userInfo = res.data
					getApp().globalData.userInfo = res.data
					uni.setStorageSync('session_key',res.data.session_key)
				
				/* 		let token = uni.getStorageSync('token')
				if(!token){
					uni.switchTab({
						url:"/pages/user/user"
					})
				}*/
				}) 
				//#endif
				//#ifdef MP-BAIDU
				this.$api.loginCode({
					code: code.code,
					type: 2
				}).then(res => {
					console.log(res)
					this.userInfo = res.data
					getApp().globalData.userInfo = res.data
					uni.setStorageSync('session_key',res.data.session_key)
				
				/* 		let token = uni.getStorageSync('token')
				if(!token){
					uni.switchTab({
						url:"/pages/user/user"
					})
				}*/
				}) 
				//#endif
				//#ifdef MP-TOUTIAO
				this.$api.loginCode({
					code: code.code,
					type: 1
				}).then(res => {
					this.userInfo = res.data
					getApp().globalData.userInfo = res.data
					uni.setStorageSync('session_key',res.data.session_key)
				 /* 	let token = uni.getStorageSync('token')
					if(!token){
						uni.navigateTo({
							url:"/pages/login/login"
						})
					} */
				}) 
				//#endif
			}
		})
	
	},
	onHide: function() {
		console.log('App Hide');
	},
	    globalData: {  
			userInfo: {}  ,
			is_park:0,
			park_name:'',
			tejia:0,
			toutiao:{},
			ershou:0,
			search_key:'',
	   },  
};
</script>

<style lang="scss">
/* 解决头条小程序组件内引入字体不生效的问题 */
/* #ifdef MP-TOUTIAO */
@font-face {
	font-family: uniicons;
	src: url('/static/uni.ttf');
}
/* #endif */

	/* 注意要写在第一行，同时给style标签加入lang="scss"属性 */
	@import "uview-ui/index.scss";

button::after{
	border: none;
}
</style>
